<template>
  <div class="xi">
    <div class="xz">
      <ul>
        <li
          v-for="(item, index) in $store.state.ly.option"
          :key="index"
          @click="xzmk(index, item)"
        >
          <span>{{ item }}</span>
        </li>
      </ul>
    </div>
    <zt
      :k="this.xuhao"
      :arr="this.arr1"
      class="youx"
      v-on:zhengjia="zhengjia"
      v-on:shanchu="shanchu"
    ></zt>
  </div>
</template>

<script>
export default {
  data() {
    return {
      xuhao: this.$store.state.ly.aa,
      arr1: [],
    };
  },
  // provide:{
  //   arr2:[0,1,2,2,2],
  //   idx:0
  // } ,

  methods: {
    async data1(s, y) {
      console.log(s, y);
      if (s == 1) {

        let d = await this.axios.get("http://localhost:7001/userinfo");
        this.arr1 = d.data;
      }
      if (s == 2) {
        let d = await this.axios.get("http://localhost:7001/useraccountall");
        this.arr1 = d.data;
      }
      if (s == 3) {
        let d = await this.axios.get("http://localhost:7001/carall");
        this.arr1 = d.data;
      }
      if (s == 4) {
        let d = await this.axios.get("http://localhost:7001/dingdanall");
        this.arr1 = d.data;
      }
      if (s == 5) {
        let d = await this.axios.get("http://localhost:7001/tezheng");
        console.log(d.data);
        this.arr1 = d.data;
      }
      // console.log(s, y);

      if (s == 6) {
        let d = await this.axios.get("http://localhost:7001/test");
        this.arr1 = d.data.ansor3;
      }
      if (s == 7) {
        let d = await this.axios.get("http://localhost:7001/test");
        this.arr1 = d.data.accountcontent;
      }
      if (s == 8) {
        let d = await this.axios.get("http://localhost:7001/details_page");
        this.arr1 = d.data;
      }
      if (s == 9) {
        let d = await this.axios.get("http://localhost:7001/details_img");
        this.arr1 = d.data;
      }
    },
    async xzmk(v, z) {
      this.xuhao = v;
      this.$store.commit("ly/changgeop", v);
      this.data1(v, z);
    },
    async zhengjia(da) {
      this.arr1.push(da);
    },
    async shanchu(a, d, san) {
      console.log(11111111);
      for (let k = 0; k < this.arr1.length; k++) {
        if (a == 1) {
          if (this.arr1[k].id == d) {
            this.arr1.splice(k, 1);
            // this.axios.get("http://localhost:7001/userde", {
            //   params: {
            //     time: d,
            //   },
            // });
          }
        } else if (a == 2) {
          if (this.arr1[k].user_name == d) {
            this.arr1.splice(k, 1);
            // this.axios.get("http://localhost:7001/userde", {
            //   params: {
            //     time: d,
            //   },
            // });
          }
        } else if (a == 3) {
          if (this.arr1[k].userid == d) {
            this.arr1.splice(k, 1);
            // this.axios.get("http://localhost:7001/userde", {
            //   params: {
            //     time: d,
            //   },
            // });
          }
        } else if (a == 4) {
          if (this.arr1[k].user_name == d && this.arr1[k].indent_info == san) {
            this.arr1.splice(k, 1);
            // this.axios.get("http://localhost:7001/userde", {
            //   params: {
            //     time: d,
            //   },
            // });
          }
        } else if (a == 5) {
          if (this.arr1[k].day_name == san && this.arr1[k].user_name == d) {
            this.arr1.splice(k, 1);
            // this.axios.get("http://localhost:7001/userde", {
            //   params: {
            //     time: d,
            //   },
            // });
          }
        } else if (a == 6) {
          if (this.arr1[k].goods_id == d) {
            this.arr1.splice(k, 1);
            // this.axios.get("http://localhost:7001/userde", {
            //   params: {
            //     time: d,
            //   },
            // });
          }
        } else if (a == 7) {
          if (this.arr1[k].time == d) {
            this.arr1.splice(k, 1);
            // this.axios.get("http://localhost:7001/cmtde", {
            //   params: {
            //     time: d,
            //   },
            // });
          }
        } else if (a == 8) {
          if (this.arr1[k].goods_id == d) {
            this.arr1.splice(k, 1);
            // this.axios.get("http://localhost:7001/userde", {
            //   params: {
            //     time: d,
            //   },
            // });
          }
        } else if (a == 9) {
          if (this.arr1[k].userid == d) {
            this.arr1.splice(k, 1);
            // this.axios.get("http://localhost:7001/userde", {
            //   params: {
            //     time: d,
            //   },
            // });
          }
        }
      }
    },
  },

  components: {
    Zt: () => import("./Zt.vue"),
  },
};
</script>

<style scoped lang=scss>
.xi {
  display: flex;
  justify-content: start;

  div.xz {
    width: 150px;
    height: 600px;
    background-color: rgb(217, 233, 235);
    display: inline-block;
    ul {
      width: 100%;
      height: 10%;
      li {
        border: 1px solid #f2f2f2;
        width: 100%;
        height: 100%;
        text-align: center;
        line-height: 65px;
      }
    }
  }
}
.youx {
  overflow: hidden;
}
</style>